<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--通用查询-->
      <queryHeader :dict="dict" :permission="permission" />
      <!--通用编辑-->
      <crudOperation :permission="permission" />
    </div>

    <!--表格渲染-->
    <el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
      <!--多选框-->
      <el-table-column type="selection" width="55" />
      <!--展示字段-->
      <el-table-column v-if="columns.visible('personType')" prop="personType" label="人员类型" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          {{ dict.label.type_org_person[scope.row.personType] }}
        </template>
      </el-table-column>
      <el-table-column v-if="columns.visible('personName')" prop="personName" label="姓名" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('personSex')" prop="personSex" label="性别" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          {{ dict.label.type_common_sex[scope.row.personSex] }}
        </template>
      </el-table-column>
      <el-table-column v-if="columns.visible('personAge')" prop="personAge" label="年龄" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('personBirthday')" prop="personBirthday" label="出生日期" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('personPhone')" prop="personPhone" label="手机号" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('personIdcard')" prop="personIdcard" label="身份证" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('personIdcardImgs')" prop="personIdcardImgs" label="身份证照片" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('personEmail')" prop="personEmail" label="邮箱" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('personWechat')" prop="personWechat" label="微信号" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('personIntroduction')" prop="personIntroduction" label="个人简介" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('personImgs')" prop="personImgs" label="个人照片" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('personPolitical')" prop="personPolitical" label="政治面貌" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          {{ dict.label.type_common_political[scope.row.personPolitical] }}
        </template>
      </el-table-column>
      <el-table-column v-if="columns.visible('personTags')" prop="personTags" label="人员标签" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('regionName')" prop="regionName" label="区域名称" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('orgName')" prop="orgName" label="组织名称" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('userId')" prop="userId" label="用户ID" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('remark')" prop="remark" label="备注" :show-overflow-tooltip="true" />

      <!--操作-->
      <el-table-column label="操作" width="130px" align="center" fixed="right">
        <template slot-scope="scope">
          <!--通用编辑删除-->
          <udOperation :data="scope.row" :permission="permission" />
        </template>
      </el-table-column>
    </el-table>

    <!--分页组件-->
    <pagination />

    <!--表单渲染-->
    <editForm :dict="dict" />
  </div>
</template>

<script>
import crudDataPerson from '@/api/business/common/org/person'
import queryHeader from './module/queryHeader'
import editForm from './module/editForm'
import CRUD, { presenter } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'
import udOperation from '@crud/UD.operation'

// crud交由presenter持有
const crud = CRUD({ title: 'DataPerson', url: 'data/person/list/page/token', crudMethod: { ...crudDataPerson }, pkIdName: 'personId' })

export default {
  name: 'DataPerson',
  components: { queryHeader, editForm, crudOperation, pagination, udOperation },
  dicts: ['type_org_person', 'type_common_sex', 'type_common_political'],
  mixins: [presenter(crud)],
  data() {
    return {
      // 对应几个按钮操作
      permission: {
        add: [],
        edit: [],
        del: []
      }
    }
  },
  methods: {

  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  /deep/ .el-input-number .el-input__inner {
    text-align: left;
  }
</style>
